package org.czl.LeetCode;

public class l643 {
    public double findMaxAverage(int[] nums, int k) {
        double ans = (double)Integer.MIN_VALUE;
        int n = nums.length;
        int sum = 0;
        for(int i = 0; i < n; i++){
            //入窗口
            sum += nums[i];
            if(i < k - 1){
                continue;
            }
            ans = Math.max(ans, (double)sum/k);
            sum -= nums[i - k + 1];
        }
        return ans;
    }
}
